Added Rich Text to SimpleTextArea!!!!#1654
Conversation
|
(also i didnt try this on any platform other than windows so idk if this works on others but i think it should be fine :)) |
|
Also, imo it would be convenient if there was a separate type of TextArea specifically for rich text, kinda like Especially since now the |
|
alrighty i committed changes yay :D |
| * @param applyToSprite Function to apply the parsed value to a font sprite (optional) | ||
| * @param stringAddition Function to add a new string at the point where the key is (optional) | ||
| */ | ||
| RichTextKey(std::string key, geode::Function<Result<T>(const std::string& value)> validCheck, geode::Function<void(const T& value, cocos2d::CCFontSprite* sprite)> applyToSprite = NULL, geode::Function<std::string(const T& value)> stringAddition = NULL) |
There was a problem hiding this comment.
Maybe this constructor could get cleaned up a bit?
RichTextKey(
std::string key,
geode::Function<Result<T>(const std::string& value)> validCheck,
geode::Function<void(const T& value, cocos2d::CCFontSprite* sprite)> applyToSprite = NULL,
geode::Function<std::string(const T& value)> stringAddition = NULL
)And also, idk how to feel about applyToSprite and stringAddition both having NULL as a default value.
I would have personally defined it something like:
RichTextKey(
std::string key,
geode::Function<Result<T>(const std::string& value)> validCheck,
) : m_key(std::move(key)), m_validCheck(std::move(validCheck)) {}
RichTextKey(
std::string key,
geode::Function<Result<T>(const std::string& value)> validCheck,
geode::Function<void(const T& value, cocos2d::CCFontSprite* sprite)> applyToSprite,
) : m_key(std::move(key), m_validCheck(std::move(validCheck)), m_applyToSprite(std::move(applyToSprite)) {}
RichTextKey(
std::string key,
geode::Function<Result<T>(const std::string& value)> validCheck,
geode::Function<void(const T& value, cocos2d::CCFontSprite* sprite)> applyToSprite,
geode::Function<std::string(const T& value)> stringAddition
) : m_key(std::move(key), m_validCheck(std::move(validCheck)), m_applyToSprite(std::move(applyToSprite)), m_stringAddition(std::move(stringAddition)) {}There was a problem hiding this comment.
Alright :D thats cool i wasent sure of what a good way of writing that was :) ill improve !
|
I still think it would be better to have a separate sorta Final thing I'll say is to make sure the code fits into the code styling guidelines and double check CONTRIBUTING.md while on that. |
|
Also whenever I have time I can try and test it on macOS |
|
Cool ty for telling me about the guidlines and stuff i didnt know about them (im noob) ill try my best to improve this code with everything in here :D will update later dw :DD |
|
well ive attempted to apply some things said in the styling guidelines :D there might be more that i forgot but i still feel like the way i placed my classes or the classes themselves is messy, i dont know why :( |
|
Also i never thought of SimpleTextArea as a "text area thats simple in implementation" cz it always looked so much more complex then the normal TextArea i though of it like "simple text area makes it simple for me to do whatever i want" unlike actual TextArea lol |
|
this might be better as smth that subclasses simpletextarea |
|
Oof :( i really dont understand the problem with it being on the simpletextarea i think its just fine but i respect the opinion and will do something whenever i have the time ig |
|
there have been some updates done to SimpleTextArea that i dont really understand and making it a harder time implementing this cz idk how this works lol, whats the Impl thing you use to separate some things in SimpleTextArea? i thought i would inhairate SimpleTextArea and make a RichTextArea and do what i did before over there but i cant because the charIteration is over at the Impl, how should i go about this? |
|
|
|
I want to see if I can try changing it to have in mind the pimpl changes. I also want to see if I can try and add stuff like links for example so it can "compete" better with I don't promise anything, it's just an idea I have. I want to help, but if I can't or don't have the time or if @abb2k prefers to go solo then I wont. |
|
i wanna add the rich text if u wanna add links using that rich text stuff later u can :D:D |
|
Im not feeling bad the help is awesome i appreciate it :D what u did helped and fixed the issues alk talked about i think but now for some reason the rich text isnt working :( i didnt have time to test at all but your changes dont seem like they should break anything so idk what happened |
|
alright i fixed rich text it fully works now :D (also i added a wave effect text key and a action for it i hope its ok that i added this i just think this is super duper cool :D:D:D:D) |
| ~RichTextArea(); | ||
|
|
||
| class RichImpl; | ||
| std::unique_ptr<SimpleTextAreaImpl> createImpl() override; |
There was a problem hiding this comment.
is this really needed instead of just exposing protected methods to simpletextarea for richtextarea to use
| if (keyDown){ | ||
| for (const auto& linkCharacter : wordClicked) | ||
| { | ||
| castedImpl->m_ogColorForLink.insert({linkCharacter, linkCharacter->getColor()}); |
There was a problem hiding this comment.
can you expose a method for this instead
| } | ||
| )); | ||
|
|
||
| castedImpl()->formatRichText(); |
There was a problem hiding this comment.
same for this, ideally impl should be opaque to richtextarea in the first place
| @@ -0,0 +1,190 @@ | |||
| #include <Geode/DefaultInclude.hpp> | |||
There was a problem hiding this comment.
these can be just moved to simpletextarea as protected functions
|
|
||
| using namespace geode::prelude; | ||
|
|
||
| class SimpleTextAreaImpl { |
There was a problem hiding this comment.
ideally this class should just not exist in the first place
|
i removed the wave effect cz ig its too much for having in the actual loader but i have 0 clue as to how to make the Impl usage good here :( if anyone else wants to help out it would be awesome :) yeah! |
| namespace geode { | ||
| using namespace geode::prelude; | ||
|
|
||
| class SimpleTextAreaImpl { |
There was a problem hiding this comment.
this is NOT what i meant, check out how other classes in geode handle actual impl stuff. impl class should NEVER be exposed in public headers
| if (keyDown){ | ||
| for (const auto& linkCharacter : wordClicked) | ||
| { | ||
| castedImpl->m_ogColorForLink.insert({linkCharacter, linkCharacter->getColor()}); |
| if (keyDown){ | ||
| for (const auto& linkCharacter : wordClicked) | ||
| { | ||
| castedImpl->m_ogColorForLink.insert({linkCharacter, linkCharacter->getColor()}); |
| } | ||
| )); | ||
|
|
||
| castedImpl()->formatRichText(); |
…ess that would maybe make it not opaque im unsure tho
…own keys properly
…keys from other classes yay :D
… applying effects on characters
|
oke this should now be working :D ive made some changes and i hope this is good now :D |
altalk23
left a comment
There was a problem hiding this comment.
impl in source yea lgtm, worse case its always changeable without breaking abi

HIII :D:D:DD
ive wanted this for a while now so i decided to make it myself :D you can now add rich text keys into a SimpleTextArea! :D
you can do so by using
registerRichTextKeyon your SimpleTextArea to add a key and tell iti think this is really cool and i hope u like what i made :D
this might not be the best implementation but u can polish it if you want ofc !!!! i tried my best :D (if you think i did anything wrong or bad i would be happy if you told me i wanna learn!! :D)